package com.itheima.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.cargo.PackingDao;
import com.itheima.domain.cargo.Packing;
import com.itheima.domain.cargo.PackingExample;
import com.itheima.service.cargo.PackingService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PackingServiceImpl implements PackingService {

    @Autowired
    private PackingDao packingDao;


    @Override
    public Packing findById(String id) {
        return packingDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(Packing packing) {
        packingDao.insertSelective(packing);
    }

    @Override
    public void update(Packing packing) {
        packingDao.updateByPrimaryKeySelective(packing);
    }

    @Override
    public void delete(String id) {
        packingDao.deleteByPrimaryKey(id);
    }

    @Override
    public List<Packing> findAll(PackingExample example) {
        return packingDao.selectByExample(example);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, PackingExample example) {
        PageHelper.startPage(pageNum, pageSize);
        List<Packing> list = packingDao.selectByExample(example);
        return new PageInfo(list, 10);
    }


}
